<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>v-on</title>
		<script src="../assets/js/vue.js"></script>
	</head>
	<body>
		<div id="app">
			本场得分：{{fenshu}}<br />
			<button v-on:click="add">加分</button>
			<button @click="ded">减分</button>
			<div>
				<h5>输入框中输入加减差值，按enter键进行加分,按空格键进行 减分</h5>
			    <input type="number" @keyup.13="onEnter" v-model="fenshu2" @keyup.32="onSpace"/>
			</div>
		</div>
		<script>
			var app = new Vue({
				el:"#app",
				data:{
				 fenshu:0,
				 fenshu2:1
				},
				methods:{
					add:function(){
						this.fenshu++
					},
					ded:function(){
						this.fenshu--
					},
					onEnter:function(){
						this.fenshu =this.fenshu+ parseInt(this.fenshu2) 
					},
					onSpace:function(){
						this.fenshu = this.fenshu - Number(this.fenshu2)
					}
				}
			})
		</script>
	</body>
</html>
